/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package services;

import dao.CategoryJpaController;
import dao.ProductJpaController;
import java.util.List;
import javax.persistence.Persistence;
import pojo.Category;
import pojo.Product;

/**
 *
 * @author khalifaabdelaziz
 */
public class ServiceProduct {
    
    public List<Product> productInCategory(Integer id){
        CategoryJpaController categoryController  = new CategoryJpaController(Persistence.createEntityManagerFactory("ServletProjectPU"));
        Category category= categoryController.findCategory(id);
        return category.getProductList();
    }
    
    public Product productData(Integer id){
        ProductJpaController productController  = new ProductJpaController(Persistence.createEntityManagerFactory("ServletProjectPU"));
       return productController.findProduct(id);   
    }
     public List<Product> products(){
        ProductJpaController productController  = new ProductJpaController(Persistence.createEntityManagerFactory("ServletProjectPU"));
       return productController.findProductEntities();
    }
    
     public List<Product> productfirstfive(){
        ProductJpaController productController  = new ProductJpaController(Persistence.createEntityManagerFactory("ServletProjectPU"));
        return productController.findProductEntities(5, 0);
    }
    
}
